//
//  PushWebviewViewController.m
//  ebook
//
//  Created by 吴超飞 on 16/3/2.
//  Copyright © 2016年 Moton. All rights reserved.
//

#import "PushWebviewViewController.h"

@interface PushWebviewViewController ()

@end

@implementation PushWebviewViewController

-(instancetype)initWithUrl:(NSString *)url title:(NSString *)title{
    
    self = [super init];
    
    if (self) {
        self.title = title;
        self.url = url;
        self.webView.frame = CGRectMake(0, 0, MTScreenW, MTScreenH - SafeAreaTopHeight);
        [self.view addSubview:self.webView];
    }
    [self webView:self.webView loadUrl:url];
    
    return self;
}

- (void)viewDidLoad {
    
    [super viewDidLoad];
    
    UIBarButtonItem *rightBarBtn = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"home_icon"] style:UIBarButtonItemStylePlain target:self action:@selector(homeBtnClick:)];
    rightBarBtn.tintColor = MTConfigColor(@"MTNavigationBar_rightItem_Color");
    self.navigationItem.rightBarButtonItem = rightBarBtn;
    
    UIBarButtonItem *leftBarBtn = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"back_arrow"] style:UIBarButtonItemStylePlain target:self action:@selector(backBtnClick:)];
    leftBarBtn.tintColor = MTConfigColor(@"MTNavigationBar_leftItem_Color");
    self.navigationItem.leftBarButtonItem = leftBarBtn;
}

-(void)homeBtnClick:(UIBarButtonItem *)item{
    
    [self.navigationController popToRootViewControllerAnimated:YES];
}

-(void)backBtnClick:(UIBarButtonItem *)item{
    
    [self.navigationController popViewControllerAnimated:YES];
}

-(void)dealloc{
    
    MTLog(@"PushWebviewViewController dealloc");
}

@end
